﻿#include "BulletIcon.h"

BulletIcon::BulletIcon(const QPoint& pos)
{
	move(pos);
	addFrame("子弹图标");
	init();
}

void BulletIcon::draw(QPainter* painter)
{
	if (m_flag)
	{
		getModel()["正常"].draw(painter, getModelRect().topLeft());
		m_NumFont.setPixelSize(20);
		painter->setPen(m_NumPen);
		painter->setFont(m_NumFont);
		QString Num = QString::number(m_num);
		Num = "X" + Num;
		;
		painter->drawText(m_TextPos-QPoint(0,getSize().height()/4), Num);
		char buff[10];
		sprintf(buff,"%02d",m_time);
		painter->drawText(m_TextPos+ QPoint(0, getSize().height() / 6), buff);
	}
	else
	{
		m_NumFont.setPixelSize(35);
		LifeIcon::draw(painter);
	}
}

void BulletIcon::ShowTime(bool flag)
{
	m_flag = flag;
}

void BulletIcon::setTime(int time)
{
	m_time = time;
}
